package cn.iocoder.yudao.module.biz.dal.mysql.expand.targets.customer;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.biz.dal.dataobject.expand.targets.customer.ExpandTargetCustomerDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.biz.controller.admin.expand.targets.customer.vo.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 拓展目标_客户 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ExpandTargetCustomerMapper extends BaseMapperX<ExpandTargetCustomerDO> {

    default PageResult<ExpandTargetCustomerDO> selectPage(ExpandTargetCustomerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExpandTargetCustomerDO>()
                .likeIfPresent(ExpandTargetCustomerDO::getCustomerName, reqVO.getCustomerName())
                .eqIfPresent(ExpandTargetCustomerDO::getEnterpriseType, reqVO.getEnterpriseType())
                .eqIfPresent(ExpandTargetCustomerDO::getBussinessResource, reqVO.getBussinessResource())
                .likeIfPresent(ExpandTargetCustomerDO::getContactName, reqVO.getContactName())
                .eqIfPresent(ExpandTargetCustomerDO::getContactNumber, reqVO.getContactNumber())
                .eqIfPresent(ExpandTargetCustomerDO::getLocation, reqVO.getLocation())
                .eqIfPresent(ExpandTargetCustomerDO::getAddress, reqVO.getAddress())
                .betweenIfPresent(ExpandTargetCustomerDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ExpandTargetCustomerDO::getOwnerUserId, reqVO.getOwnerUserId())
                .orderByDesc(ExpandTargetCustomerDO::getId));
    }

    List<Map<String,Object>> getExpandTargetCustomerYear(Long tenantId);

    /**
     * 检查拓展目标_客户是否存在
     * @param name
     * @return 存在返回1，不存在返回0
     */
    Integer checkExistByName(@Param("name") String name);
}